package com.example.controller.question;

import com.example.domain.question.QuestionDetailVO;
import com.example.domain.question.dto.QuestionQueryDTO;
import com.example.service.question.IQuestionServer;
import oj.common.core.controller.BaseController;
import oj.common.core.domain.PageQueryDTO;
import oj.common.core.domain.Result;
import oj.common.core.domain.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/question")
public class QuestionController extends BaseController {
    @Autowired
    private IQuestionServer questionServer;

    @RequestMapping("/semiLogin/list")
    public TableDataInfo list(QuestionQueryDTO questionQueryDTO) {
        return questionServer.list(questionQueryDTO);
    }
    //这里的话先进行展示一个题目详情的接口
    //前端的话，有一个上一个题目和下一个题目，所以在切换的时候，需要设计两个接口，来调用这个详情的接口
    @GetMapping("/detail")
    public Result<QuestionDetailVO> detail(Long questionId) {
        return Result.success(questionServer.detail(questionId));
    }
    @GetMapping("/preQuestionDetail")
    public Result<String> preQuestionDetail(Long questionId) {
        return Result.success(questionServer.preQuestionDetail(questionId));
    }
    @GetMapping("/nextQuestionDetail")
    public Result<String> nextQuestionDetail(Long questionId) {
        return Result.success(questionServer.nextQuestionDetail(questionId));
    }
    @GetMapping("/listQuestion")
    //参数应该是一个dto
    public TableDataInfo listQuestion(PageQueryDTO pageQueryDTO) {
        //首先接收的参数有页数，一页显示的数据多少，这里还根据题目进行模糊搜索，还有困难程度
        return getTableDataInfo(questionServer.selectQuestionList(pageQueryDTO));
    }
}
